<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:KmlFormat="http://earth.google.com/KmlFormat/2.2"
                xmlns:str="http://exslt.org/strings" exclude-result-prefixes="KmlFormat str">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:param name="placemarkName"></xsl:param>
  <xsl:template match="KmlFormat:KmlFormat/KmlFormat:Document">
    <rss xmlns:georss="http://www.georss.org/georss" version="2.0">
      <channel>
        <title>GeoRSS</title>
        <description>International earthquake observation labs</description>
        <link href="http://example.org/"/>
        <!--<updated>2005-12-13T18:30:02Z</updated>-->
        <!--<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>-->
        <xsl:for-each select="KmlFormat:Folder/KmlFormat:Placemark">
          <xsl:if test="KmlFormat:name=$placemarkName or $placemarkName=''">
            <item>
              <title>
                <xsl:value-of select="KmlFormat:name"/>
              </title>
              <link>#</link>
              <author>Author name</author>
              <!--<pubDate>Sun, 17 Jun 2007 06:44:00 +0000</pubDate>-->
              <description>
                <xsl:value-of select="KmlFormat:description"/>
              </description>

              <xsl:if test="KmlFormat:Point">
                <georss:point>
                  <xsl:variable name="coordinatesParts" select="str:tokenize(KmlFormat:Point/KmlFormat:coordinates,',')" />
                  <xsl:value-of select="$coordinatesParts[2]"/>
                  <xsl:value-of select="' '"/>
                  <xsl:value-of select="$coordinatesParts[1]"/>
                </georss:point>
              </xsl:if>
              <xsl:if test="KmlFormat:LineString">
                <georss:line>
                  <xsl:call-template name="GenerateLineStringCoordinates">
                    <xsl:with-param name="coordinatesPairs" select="str:tokenize(KmlFormat:LineString/KmlFormat:coordinates, ' ')"/>
                  </xsl:call-template>
                </georss:line>
              </xsl:if>
            </item>
          </xsl:if>
        </xsl:for-each>
      </channel>
    </rss>
  </xsl:template>
  <xsl:template name="GenerateLineStringCoordinates">
    <xsl:param name="coordinatesPairs" />
    <xsl:param name="coordinatesPairsIndex">1</xsl:param>
    <xsl:variable name="coordinates" select="str:tokenize($coordinatesPairs[$coordinatesPairsIndex], ',')"/>
    <xsl:value-of select="$coordinates[2]"/>
    <xsl:value-of select="' '"/>
    <xsl:value-of select="$coordinates[1]"/>
    <xsl:if test="$coordinatesPairsIndex &lt; count($coordinatesPairs)">
      <xsl:value-of select="' '"/>
      <xsl:call-template name="GenerateLineStringCoordinates">
        <xsl:with-param name="coordinatesPairs" select="$coordinatesPairs" />
        <xsl:with-param name="coordinatesPairsIndex" select="$coordinatesPairsIndex + 1" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>